home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / FTP / Mirror2.3 / support / cyber-patches next >
Encoding:
Text File  |  1994-01-14  |  2.9 KB  |  108 lines

  1. # From: x920031@rubb.rz.ruhr-uni-bochum.de (Jost Krieger)
  2. #
  3. # Now here is my file cyber.pl, accessed via external_mapping=cyber.pl.
  4. # Problems are: I get "malformed cmd-links" for each access to the file.
  5. #For the first access I get one malformed cmd-link for the tempname kludge
  6. #(well deserved), and for any further access in the same run, I get one
  7. #malformed ... for each subroutine. It works, though.
  8. #
  9. #Remark: this is for a filesystems where filenames are restricted to
  10. #31 chars *after* some funny remapping.
  11. #
  12. #=========================================================================
  13.  
  14. #override filename (very unclean)
  15.  
  16. sub filename_to_tempname
  17. {
  18.     local( $dir, $file ) = @_;
  19.  
  20.     # dir 
  21.     return "$dir.$file.";
  22. }
  23.  
  24. package extmap;
  25.  
  26. # constant for cyber file name length
  27. $cyber_length_max = 29;        # leave room for temp name letters ...
  28.  
  29.  
  30. sub map {
  31.     local($dest_path) = @_;
  32.     local($dest_file,@new_path);
  33.     local(@old_path)=split("/",$dest_path);
  34.     for $dest_file (@old_path) {
  35.        if(&cyber_length($dest_file)>$cyber_length_max) {
  36.            $dest_file = &cyber_length_trim($dest_file,$cyber_length_max);
  37.        }
  38.            push(@new_path, $dest_file);
  39.     }
  40.         $dest_path=join("/",@new_path);
  41.     return $dest_path;
  42. }
  43.  
  44.  
  45. # cut name length for cyber
  46. sub cyber_length_trim {
  47.     local ($unix_name, $max_name) = @_;
  48.     local ($postfix); 
  49.     local($toomuch)=&cyber_length($unix_name)-$max_name; 
  50.  
  51.     $unix_name = reverse($unix_name);
  52. #    print $unix_name,$toomuch,"\n";
  53.  
  54.     if( $unix_name =~ s/^(..?.?\.)//) {
  55.         $postfix = $1;
  56.     }
  57.  
  58.     if ($toomuch>0) {
  59.         $unix_name =~ tr/A-Z/a-z/;
  60.         $toomuch = &cyber_length(reverse($postfix . $unix_name))-$max_name; 
  61.     }
  62. #    print $unix_name,$toomuch,"\n";
  63.  
  64.     while($toomuch>0) {
  65.         last unless ($unix_name =~ s/[aeiou]// > 0);
  66.         $toomuch -= 1;
  67.     }
  68. #    print $unix_name,$toomuch,"\n";
  69.  
  70.     if ($toomuch > 0) {
  71.         $unix_name = substr($unix_name, $toomuch);
  72.     }
  73. #    print $unix_name,$toomuch,"\n";
  74.  
  75.     $unix_name = reverse($postfix . $unix_name);
  76. }
  77.  
  78. # file name length on cyber
  79. sub cyber_length {
  80.     local ($unix_name) = @_;
  81.     local ($length) = 0;
  82.     
  83.     $length +=1 if $unix_name =~ /^[0-9]/;
  84. #    print $unix_name,$length,"\n";
  85.     $length -=1 if $unix_name =~ /[A-Z]$/;
  86. #    print $unix_name,$length,"\n";
  87.     $length += 3* ($unix_name =~ tr/A-Za-z0-9$._][-//cd);
  88. #    print $unix_name,$length,"\n";
  89.     $length += 2* ($unix_name =~ tr/-][//d);
  90. #    print $unix_name,$length,"\n";
  91.     $length += ($unix_name =~ tr/0-9$._//d);
  92. #    print $unix_name,$length,"\n";
  93.     $length += ($unix_name =~ tr/A-Z/A/s);
  94. #    print $unix_name,$length,"\n";
  95.     $length += 2*($unix_name =~ tr/A-Z//d);
  96. #    print $unix_name,$length,"\n";
  97.     $length += length($unix_name);
  98. #    print $unix_name,$length,"\n";
  99.     $length;
  100. }
  101.  
  102. #=========================================================================
  103. #
  104. #--
  105. #Jost Krieger, Rechenzentrum der Ruhr-Universitaet Bochum
  106. #x920031@rubb.rz.ruhr-uni-bochum.de
  107. #g=Jost;s=Krieger;ou=ruba;ou=rz;pd=ruhr-uni-bochum;ad=dbp;c=de
  108.